package com.gs.controller;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gs.pojo.Attribute;
import com.gs.pojo.Passenger;
import com.gs.pojo.RoomSet;
import com.gs.pojo.StayRegister;
import com.gs.service.attribute.AttributeService;
import com.gs.service.passenger.PassengerService;
import com.gs.service.roomSet.RoomSetService;
import com.gs.service.stayregister.StayRegisterService;
import com.gs.utils.Page;

@Controller
@RequestMapping("/StayRegister")
public class StayRegisterController {

	@Resource
	private AttributeService attributeService;

	@Resource
	private StayRegisterService stayRegisterService;
	
	@Resource
	private PassengerService passengerService;
	
	@Resource
	private RoomSetService roomSetService;
	
	int fangjianId=0;
	String lvkeName="";
	double zhuDianTianShu=0;                      //住店天数
    double shengZhuDianTianShu=0;                 //剩住店天数
	double zhuDianTianShuOne=0;                   //住店天数
	
	//旅客登记list
	@RequestMapping("/tolist.do")
	public String tolist(@RequestParam(value="currentPage",required=false,defaultValue="1")Integer currentPage,
			@RequestParam(value="LvKeLeiXingId",required=false,defaultValue="55")Integer LvKeLeiXingId,
			@RequestParam(value="isBillID",required=false,defaultValue="68")Integer isBillID,
			@RequestParam(value="txtname",required=false,defaultValue="")String txtname,Model model) {
		List<StayRegister> listAll = stayRegisterService.selectAll();
		Date date = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Timestamp timestamp = Timestamp.valueOf(sdf.format(date)); //当前时间转化成字符串
		int id = 0;
		long xiangchatianshu = 0;
		long days = 0;
		long hours = 0;
		String zhuSu = "";
		for (int i = 0; i < listAll.size(); i++) {
			id = listAll.get(i).getId();
			Timestamp registerTime = listAll.get(i).getRegisterTime();//登记时间
			zhuSu = listAll.get(i).getStayNumber();//住店天数
			xiangchatianshu = timestamp.getTime() - registerTime.getTime();//相差的毫秒数
			days = xiangchatianshu/(1000*60*60*24); //入住天数
			hours = xiangchatianshu/(1000*60*60) - days*24;//入住小时数

			if  (Long.parseLong(zhuSu)<=days) {
				if (hours>0) {
					stayRegisterService.updateRemind(id, 1);
				}
			}
		}
		//控制首页和尾页
		if (currentPage<=0) {
			currentPage = 1;
		}
		List<Attribute> listOne = attributeService.selectIsPay();
		Page<StayRegister> vo=new Page<StayRegister>();
		vo.setCurrentPage(currentPage);
		vo = stayRegisterService.pageFuzzyselectOne(LvKeLeiXingId, isBillID, txtname, vo);
		model.addAttribute("list",vo);
		model.addAttribute("listOne",listOne);
		model.addAttribute("LvKeLeiXingId",LvKeLeiXingId);
		model.addAttribute("isBillID",isBillID);
		model.addAttribute("txtname",txtname);
		return "/stayregister/list";
	}
	//团队登录list
	@RequestMapping("/toteamlist")
	public String toteamlist(@RequestParam(value="currentPage",required=false,defaultValue="1")Integer currentPage,
			@RequestParam(value="LvKeLeiXingId",required=false,defaultValue="56")Integer LvKeLeiXingId,//56为团队
			@RequestParam(value="isBillID",required=false,defaultValue="68")Integer isBillID,
			@RequestParam(value="txtname",required=false,defaultValue="")String txtname,
			Integer tuanDuiID,String teamNameId, String teamCodeId, String principalId,
			String contactPhoneNUmberId, String registerTimeId,Model model) {
		List<StayRegister> listTeam=null;
		List<StayRegister> listAll=stayRegisterService.selectAll();
		Date date=new Date();
		 SimpleDateFormat dformat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");   //设置日期格式
		Timestamp timestamp=Timestamp.valueOf(dformat.format(date)) ;  //将当前时间转为字符串
		int id=0;
		long xiangChaTianShu;
		long days;
		long hours;
		String zhuSu="";
		double teamSumConst=0;
		for (int i = 0; i < listAll.size(); i++) {
			id=listAll.get(i).getId();                                                            //获取ID
			Timestamp registerTime=listAll.get(i).getRegisterTime();                              //获取登记时间
			zhuSu=listAll.get(i).getStayNumber();                                                 //获取登记时间
			
			xiangChaTianShu=timestamp.getTime()-registerTime.getTime();                           //当前时间-登记时间
			days=xiangChaTianShu/(1000 * 60 * 60 * 24);                                           //转化为天
			hours=xiangChaTianShu/(1000 * 60 * 60 )-days*24;                                              //转化为小时
			
			if (Long.parseLong(zhuSu)<=days) {
				if (hours>0) {
					stayRegisterService.updateRemind(id, 1);
				}
			}
		}
		List<Attribute> listOne=attributeService.selectIsPay();
		if (tuanDuiID==null) {
			listTeam=this.stayRegisterService.selectFormTeamIdTwo(isBillID);
		}else {
			listTeam=this.stayRegisterService.selectFormTeamId(tuanDuiID, isBillID);
		}
		if (currentPage==null) {
			currentPage=1;
		}else if (currentPage==0) {
			currentPage=1;
		}
		
		for (int i = 0; i < listTeam.size(); i++) {
			teamSumConst+=listTeam.get(i).getSumConst();
		}

		Page<StayRegister> vo=new Page<StayRegister>();
		vo.setCurrentPage(currentPage);
		if (tuanDuiID==null) {
			vo=this.stayRegisterService.pageFuzzyselectThree(isBillID, txtname, vo);
		}else {
			vo=this.stayRegisterService.pageFuzzyselectTwo(tuanDuiID, isBillID, txtname, vo);
		}
		model.addAttribute("list",vo);
		model.addAttribute("listOne",listOne);
		model.addAttribute("LvKeLeiXingId",LvKeLeiXingId);
		model.addAttribute("isBillID",isBillID);
		model.addAttribute("txtname",txtname);
		model.addAttribute("tuanDui",tuanDuiID);
		model.addAttribute("teamNameId",teamNameId);
		model.addAttribute("teamCodeId",teamCodeId);
		model.addAttribute("principalId",principalId);
		model.addAttribute("contactPhoneNUmberId",contactPhoneNUmberId);
		model.addAttribute("registerTimeId",registerTimeId);
		model.addAttribute("teamSumConst",teamSumConst);
		return "/stayregister/list";
	}

	//查询团队消费总金额
	@RequestMapping
	public @ResponseBody Object ajaxSelectTeamSumcont(Integer tuanDuiID, Integer isBillID) {
		double teamSumConst=0;
		List<StayRegister> listTeam=this.stayRegisterService.selectFormTeamId(tuanDuiID, isBillID);
		for (int i = 0; i < listTeam.size(); i++) {
			teamSumConst+=listTeam.get(i).getSumConst();
		}

		return teamSumConst;
	}
	//跳转到添加页面
	@RequestMapping("/toadd")
	public String toadd(){
		return "/stayregister/add";
	}
	
	/*·--------------------登记 start-------------------·*/
	//登记
		@RequestMapping("/toregister")
		public String toregister(int id,String roomNumber,Integer LvKeLeiXingId,Model model) {
			List<Attribute> listGender=attributeService.selectGender();                      //性别
			List<Attribute> listNation=attributeService.selectNation();                      //民族
			List<Attribute> listPassengerLevel=attributeService.selectPassengerLevel();      //旅客级别
			List<Attribute> listEducationDegree=attributeService.selectEducationDegree();    //文化程度
			List<Attribute> listPapers=attributeService.selectPapers();                      //证件类型
			List<Attribute> listThingReason=attributeService.selectThingReason();            //事由
			model.addAttribute("roomNumber",roomNumber);
			model.addAttribute("stayRegisterId",id);
			model.addAttribute("listGender",listGender);
			model.addAttribute("listNation",listNation);
			model.addAttribute("listPassengerLevel",listPassengerLevel);
			model.addAttribute("listEducationDegree",listEducationDegree);
			model.addAttribute("listPapers",listPapers);
			model.addAttribute("listThingReason",listThingReason);
			model.addAttribute("LvKeLeiXingId",LvKeLeiXingId);
			return "/stayregister/register";
		}
		
		@RequestMapping("/register")
		public String register(Passenger passenger,Integer LvKeLeiXingId) {
			Integer lvkeid = passenger.getLvKeID();
			if (lvkeid == null) {
				passengerService.insertAll(passenger);
				lvkeid =passenger.getId();
			} else {
				passenger.setId(passenger.getStayRegisterID());
				passengerService.updateById(passenger);
			}
			stayRegisterService.insertStayregisterdetails(passenger.getStayRegisterID(), lvkeid);
			
			return "redirect:/StayRegister/tolist.do?LvKeLeiXingId="+LvKeLeiXingId;
		}
		@ResponseBody //根据旅客异步模糊查询旅客信息
		@RequestMapping(value="/selectPassenger")
		public Object selectPassenger(String txtname){
			if(txtname==null){
				txtname="";
			}
			List<Passenger> list=passengerService.selectAjaxList(txtname);
	       
	       return list;
		}
		
		@ResponseBody //根据ID异步加载旅客信息
		@RequestMapping(value="/confirmPassenger")
		public Object confirmPassenger(Integer id){
		  Passenger list=passengerService.selectById(id);
	       return list;
		}
		/*------------登记  end-----------*/
		
	  /*-------------- 安排房间 start--------------*/	
	 //安排房间
	@RequestMapping("/toarrangeroom")
	public String toarrangeroom(Integer tuanDuiID,Integer LvKeLeiXingId,Model model){
		List<RoomSet> list=roomSetService.selectAll();
		List<Attribute> listPassengerType=attributeService.selectPassengerType();     //旅客类别
		List<Attribute> listBillUnit=attributeService.selectBillUnit();              //结账单位
		List<Attribute> listPayWay=attributeService.selectPayWay();                 //结账方式
		List<Attribute> listRentOutType=attributeService.selectRentOutType();      //出租方式
		model.addAttribute("listPassengerType",listPassengerType);
		model.addAttribute("listBillUnit",listBillUnit);
		model.addAttribute("listPayWay",listPayWay);
		model.addAttribute("listRentOutType",listRentOutType);
		model.addAttribute("list",list);
		model.addAttribute("tuanDuiID",tuanDuiID);
		model.addAttribute("LvKeLeiXingId",LvKeLeiXingId);
		return "/stayregister/arrangeroom";
	}
	
	@RequestMapping("/arrangeroom")
	public String arrangeroom(StayRegister stayRegister,Integer LvKeLeiXingId)	{
		stayRegister.setIsBillID(68); //68为结账
		if (stayRegister.getReceiveTargetID() == null) {
			stayRegister.setReceiveTargetID(2);//设置
		}
		int fangJianId = stayRegister.getRoomID();
		RoomSet roomSet = roomSetService.selectById(fangJianId);  			//根据 房间ID 查询房间信息
		int chuZuFangShiId=stayRegister.getRentOutTypeID();                           //获取 出租方式
		int tianShuOrZhongDian=Integer.parseInt(stayRegister.getStayNumber());       //获取 住店天数/小时
		if (chuZuFangShiId == 26) {       //26为全日
			double fangJia = roomSet.getStandardPriceDay();  //获取房间价格
			double sumConst = fangJia*tianShuOrZhongDian;
			stayRegister.setSumConst(sumConst);
		} else if(chuZuFangShiId==25){   //终点房
			double fangJia = roomSet.getStandardPrice();
			int zuiDaShiChang=Integer.parseInt(roomSet.getMaxDuration());              //获取最大时长
			int shouDuanShiChang=Integer.parseInt(roomSet.getFirstDuration());         //获取首段时长
			double shouDuanJiGe=roomSet.getFirstPrice();                              //获取首段价格
			if (shouDuanShiChang >= tianShuOrZhongDian) {
				double sumConst = shouDuanJiGe ;
				stayRegister.setSumConst(sumConst);
			} else if (shouDuanShiChang <= tianShuOrZhongDian && tianShuOrZhongDian <= zuiDaShiChang) {
				int xiaoShi=tianShuOrZhongDian-shouDuanShiChang;                 //如果输入的钟点数 在 最大时长的范围之内
				double sumConst= shouDuanJiGe+xiaoShi*fangJia;                   // 且大于等于首段时长 ，那么 计算出
				stayRegister.setSumConst(sumConst);                            // 首段价格 加上 钟点数乘以 多出的每小时价格
			}else if(tianShuOrZhongDian>zuiDaShiChang){
				stayRegister.setSumConst(roomSet.getStandardPriceDay()); //假如 输入的钟点数大于最大时长那么 按一天的价格计算
			}
		}
		stayRegisterService.insertAll(stayRegister); //新增
		System.out.println("id="+stayRegister.getId());
		int id = stayRegister.getId();
		stayRegister.setDepositStayRegisterID(id);
		stayRegister.setDepositRegisterTime(stayRegister.getRegisterTime()); 
		stayRegisterService.insertDeposit(stayRegister); //新增押金信息
		RoomSet newRoomSet=new RoomSet();
		newRoomSet.setId(fangJianId);
		newRoomSet.setRoomStateID(65);
		roomSetService.updateByIdToRoomState(newRoomSet);
		return "redirect:/StayRegister/tolist.do?LvKeLeiXingId="+LvKeLeiXingId;
	}
		//ajax 安排房间的房间
		@ResponseBody
		@RequestMapping(value="/guestRoomLevelSelectRoom")
		public Object guestRoomLevelSelectRoom(Integer guestRoomLevelID){
			List<RoomSet> list=null;
			if (guestRoomLevelID==0) {
				list=roomSetService.selectAll();
			}else {
				list=roomSetService.levelSelectInformation(guestRoomLevelID);
			}
	       return list;
		}
	
	/*------------------安排房间 end-------------*/
	
	/*------------------换房 start-------------*/
	@RequestMapping("/tochangroom")
	public String tochangroom(Integer id,String lvKeName,Integer LvKeLeiXingId, Model model) {
		fangjianId = id;
		lvkeName =lvKeName;
		Date date = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Timestamp timestamp = Timestamp.valueOf(sdf.format(date));
		long xiangChaTianShu;                       //相差时间：毫秒
		long days=0;                                  //相差天数
		long hours=0;                                 //相差小时
		long daysOne=0;
		long hourOne=0;
		String zhuSu="";                            //住宿天数或小时
		Timestamp registerTime;                     //登记时间
		double yaJin=0;             				//押金
		double shangPinXiaoFei=0;   				//商品消费
		double zhuSuFei=0;        				    //住宿费
		double fangJia=0;         				    //房价
		int chuZuFangShi=0;      				    //出租方式
		String huanFangShiJian;                     //换房时间
		List<StayRegister> list =stayRegisterService.selectChangRoom(fangjianId);
		List<StayRegister> listSource = stayRegisterService.selectMoney(id);
		registerTime = list.get(0).getRegisterTime();      //获取登记时间
		zhuSu = list.get(0).getStayNumber();			//获取住宿天数或时长
		fangJia = list.get(0).getRoomStandardPriceDay();  //获取房价 每天
		chuZuFangShi = list.get(0).getRentOutTypeID();  //获取出租方式
		huanFangShiJian = String.valueOf(list.get(0).getChangRoomTime());
		if (huanFangShiJian == "" || huanFangShiJian =="null") {
			xiangChaTianShu = timestamp.getTime() - registerTime.getTime();
			days = xiangChaTianShu/(1000*60*60*24);
			hours = xiangChaTianShu/(1000*60*60) - days*24 ;
			if (chuZuFangShi == 26) { //26为全日方式
				if (hours<6) {
					zhuSuFei = days*fangJia;
					zhuDianTianShu = days;
				} 
				if (hours>=6 & hours <= 15) {
					zhuSuFei = days*fangJia+(0.5*fangJia);
					zhuDianTianShu = days +0.5 ;
				}else if (hours > 15) {
					zhuSuFei=(days+1)*fangJia;
					zhuDianTianShu=days+1;
				}
			}
			shengZhuDianTianShu=Integer.parseInt(zhuSu)-zhuDianTianShu;
		}else {
			xiangChaTianShu = timestamp.getTime() - registerTime.getTime();   //当前时间-登记时间
			days =xiangChaTianShu/(1000*60*60*24);
			hours = xiangChaTianShu/(1000*60*60) -days*24;
			
			xiangChaTianShu=timestamp.getTime()-Timestamp.valueOf(huanFangShiJian).getTime();//当前时间-上一次换房时间
			daysOne=xiangChaTianShu/(1000 * 60 * 60 * 24);                          //转化为天
			hourOne=xiangChaTianShu/(1000 * 60 * 60 )-days*24;                      //转化为24小时之内
			if(chuZuFangShi==26){
				if(hourOne<6){
					zhuSuFei=daysOne*fangJia;
					zhuDianTianShuOne=daysOne;
				}
				if (hourOne>=6 & hourOne<=15) {
					zhuSuFei=daysOne*fangJia+(0.5*fangJia);
					zhuDianTianShuOne=daysOne+0.5;
				}else if(hourOne>15){
					zhuSuFei=(daysOne+1)*fangJia;
					zhuDianTianShuOne=daysOne+1;
				}
				if(hours<6){
					zhuDianTianShu=days;
				}
				if (hours>=6 & hours<=15) {
					zhuDianTianShu=days+0.5;
				}else if(hours>15){
					zhuDianTianShu=days+1;
				}
			}
			shengZhuDianTianShu=Integer.parseInt(zhuSu)-zhuDianTianShuOne-zhuDianTianShu;
		}
		for (int i = 0; i < list.size(); i++) {
			yaJin += list.get(i).getDeposit();
		}
		for (int i = 0; i < listSource.size(); i++) {
			shangPinXiaoFei += listSource.get(i).getConsumptionMoney();
		}
		model.addAttribute("lvKeName",lvKeName);
		model.addAttribute("list",list);
		model.addAttribute("yaJin",yaJin);
		model.addAttribute("shangPinXiaoFei",shangPinXiaoFei);
		model.addAttribute("zhuSuFei",zhuSuFei);
		model.addAttribute("stayId",id);
		model.addAttribute("zhuDianTianShu",zhuDianTianShu);
		model.addAttribute("timestamp",timestamp);
		model.addAttribute("LvKeLeiXingId",LvKeLeiXingId);
		return  "/stayregister/changroom";
	}
	
	@RequestMapping("/confirmChangRoom")
	public String confirmChangRoom(Integer id, Integer roomId, Double changRoomMoney, 
			Timestamp changRoomTime,Integer LvKeLeiXingId,Model model) {
		int chuZuFangShi=0;      				    //出租方式
		String huanFangCiShu="";                    //换房次数
		double fangJiaDay=0;                          //房价/天
		double fangJiaHour=0;                         //房价/小时
		double zongFeiYong=0;                         //总费用
		int zhuDianShiJian;                         //住店时间
		int jiuFangJianId=0;                        //旧房间id
		double JiuHuanFanFei;                       //旧换房费
		double shangPinXiaoFei=0;                   //商品消费
        int zuiDaShiChang=0;                        //新最大时长限制
        int shouDuanShiChang=0;                     //新首段时长
        double shouDuanJiaGe=0;                     //新首段价格
		List<StayRegister> list = stayRegisterService.selectChangRoom(id);
		List<StayRegister> listShangPin = stayRegisterService.selectMoney(id);
		RoomSet roomSet = roomSetService.selectById(roomId);
		chuZuFangShi=list.get(0).getRentOutTypeID();                                   //获取出租方式
		zhuDianShiJian=Integer.parseInt(list.get(0).getStayNumber());                  //获取住店时间
		huanFangCiShu=list.get(0).getChangingRoomNumber();                             //获取换房次数
		jiuFangJianId=list.get(0).getRoomID();                                         //获取旧房间id
		JiuHuanFanFei=list.get(0).getChangRoomMoney();                                 //获取旧换房费
		
		fangJiaDay=roomSet.getStandardPriceDay();                                    //获取新房价/天
		fangJiaHour=roomSet.getStandardPrice();                                      //获取新房价/小时
		zuiDaShiChang=Integer.parseInt(roomSet.getMaxDuration());                    //获取新最大时长
		shouDuanShiChang=Integer.parseInt(roomSet.getFirstDuration());               //获取新首段时长
		shouDuanJiaGe=roomSet.getFirstPrice();													//获取首段价格
		
		for (int i = 0; i < listShangPin.size(); i++) {
			zongFeiYong += listShangPin.get(i).getConsumptionMoney();
		}
		if (chuZuFangShi == 26) {
			zongFeiYong=JiuHuanFanFei+changRoomMoney+shangPinXiaoFei+shengZhuDianTianShu*fangJiaDay;
		} else if (chuZuFangShi == 25){
			if (shouDuanShiChang > zhuDianShiJian) {
				zongFeiYong=JiuHuanFanFei+changRoomMoney+shangPinXiaoFei+shouDuanJiaGe;
			}else if(zhuDianShiJian>=shouDuanShiChang & zhuDianShiJian<=zuiDaShiChang){
				double jiSuan=(zhuDianShiJian-shouDuanShiChang)*fangJiaHour;
				zongFeiYong=JiuHuanFanFei+changRoomMoney+shangPinXiaoFei+shouDuanJiaGe+jiSuan;
			}else {
				zongFeiYong=JiuHuanFanFei+changRoomMoney+shangPinXiaoFei+fangJiaDay;
			}
		}
		if (huanFangCiShu==null || huanFangCiShu=="") {
			huanFangCiShu="1";
		}else{
			huanFangCiShu=String.valueOf(Integer.parseInt(huanFangCiShu)+1);
		}
		StayRegister stayRegister=new StayRegister();
		RoomSet roomOne=new RoomSet();
		RoomSet roomTwo=new RoomSet();
		stayRegister.setId(id);
		stayRegister.setRoomID(roomId);
		stayRegister.setSumConst(zongFeiYong);
		stayRegister.setChangingRoomNumber(huanFangCiShu);
		stayRegister.setChangRoomMoney(changRoomMoney+JiuHuanFanFei);
		stayRegister.setChangRoomTime(changRoomTime);
		roomOne.setId(jiuFangJianId);
		roomOne.setRoomStateID(1);
		roomTwo.setId(roomId);
		roomTwo.setRoomStateID(65);
		
		roomSetService.updateByIdToRoomState(roomOne);
		roomSetService.updateByIdToRoomState(roomTwo);
		stayRegisterService.updateChangRoom(stayRegister);
		
		return "redirect:/StayRegister/tolist.do?LvKeLeiXingId="+LvKeLeiXingId;
	}
	
	@ResponseBody
	@RequestMapping(value="/changRoomSelectPassenger")
	public Object changRoomSelectPassenger(String roomNumber){
	   if(roomNumber==null){
		   roomNumber="";
	   }
	   List<RoomSet> list=roomSetService.selectInformation(roomNumber);
       return list;
	}
	
	/*------------------换房 end-------------*/
	
	/*-------押金的详细信息start----------*/
	@RequestMapping("/todeposit")
	public String todeposit(Integer id,String lvKeName,Integer LvKeLeiXingId, Model model) {
		
		fangjianId = id;
		lvkeName=lvKeName;
		List<StayRegister> list = stayRegisterService.selectDepositById(id);
		List<Attribute> list2=attributeService.selectPayWay();
		model.addAttribute("list",list);
		model.addAttribute("listTwo",list2);
		model.addAttribute("lvKeName",lvKeName);
		model.addAttribute("stayId",id);
		model.addAttribute("LvKeLeiXingId",LvKeLeiXingId);
		return "/stayregister/deposit";
	}
	
	@RequestMapping("/deposit")
	public String deposit(StayRegister stayRegister,Integer LvKeLeiXingId,Model model) {
		Date date = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Timestamp timestamp=Timestamp.valueOf(sdf.format(date)) ;  //将当前时间转为字符串
		stayRegister.setDepositRegisterTime(timestamp);
		model.addAttribute("lvKeName", lvkeName);
		model.addAttribute("LvKeLeiXingId",LvKeLeiXingId);
		stayRegisterService.insertDeposit(stayRegister);		
		return "redirect:/StayRegister/todeposit.do?id="+fangjianId;
	}
	/*-------押金的详细信息end----------*/
	
	/*------------------ 消费明细 start------------------*/	
	
	@RequestMapping("/toconsumption")
	public String toconsumption(Integer id,String lvKeName,Integer currentPage,
			Integer LvKeLeiXingId,Integer isBillID,Model model)  {
		lvkeName=lvKeName;
		Page<StayRegister> vo=new Page<StayRegister>();
		if (currentPage==null) {
			currentPage=1;
		}else if (currentPage==0) {
			currentPage=1;
		}
		vo.setCurrentPage(currentPage);
		List<Attribute> listOne=attributeService.selectCommodityType();
		vo=stayRegisterService.pageConsumption(id, vo);
		model.addAttribute("listOne",listOne);
		model.addAttribute("stayId",id);
		model.addAttribute("lvKeName",lvKeName);
		model.addAttribute("list",vo);
		model.addAttribute("LvKeLeiXingId",LvKeLeiXingId);
		model.addAttribute("isBillID",isBillID);
		return "/stayregister/consumption";
	}
	
	
}
